package com.star.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.star.model.MessageModel;
import com.star.model.PlModel;
import com.star.service.MessageService;
import com.star.service.PlDealWithService;
import com.star.service.PlService;

@Service
public class PlDealWithServiceImpl implements PlDealWithService {

	@Autowired
	private MessageService messageService;

	@Autowired
	private PlService plService;

	// 建楼
	public boolean dealCorePl(Integer newsId, String content, Integer uid) {

		boolean flag = plService.optPlData(newsId, content);
		if (!flag) {
			return Boolean.FALSE;
		}
		PlModel plmodel = plService.queryByNewsId(newsId);
		try {
			MessageModel messageModel = new MessageModel();
			messageModel.setMessage(content.trim());
			messageModel.setNewsId(newsId);
			messageModel.setUid(uid);
			messageModel.setPlId(plmodel.getId());
			messageModel.setFromId(uid);
			messageService.insertMessage(messageModel);
		} catch (Exception e) {
			e.printStackTrace();
			return Boolean.FALSE;
		}
		return Boolean.TRUE;
	}

}
